package cn.kgc.dto;

import cn.kgc.commons.util.AddGroup;
import cn.kgc.commons.util.UpdateGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.*;

/**
 * <p></p>
 *
 * @author 李孟鸠
 * @Date: 2022年11月28日9:06
 *
 * 新增和更新的时候使用同一个类，接收前端传入的参数
 * 新增和更新的后端验证规则是不同的，使用JSR303验证时，需要区分是新增还是更新的操作
 */
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@Builder
@ApiModel
public class PmsBrandDTO {

    @ApiModelProperty(name = "id", value = "主键", dataType = "int")
    @NotNull(message = "id:主键不能为空",groups ={ UpdateGroup.class})
    private Long id;  //主键

    @ApiModelProperty(name = "name", value = "品牌名", dataType = "java.lang.String")
    @NotBlank(message = "name:品牌名不能为空",groups = {AddGroup.class,UpdateGroup.class})
    @Length(max=50,message = "品牌名字符长度不超过50")
    private String name;

    @ApiModelProperty(name = "logo", value = "品牌logo地址", dataType = "java.lang.String")
    private String logo;

    @ApiModelProperty(name = "descript", value = "介绍", dataType = "java.lang.string")
    private String descript;    //介绍

    @ApiModelProperty(name = "firstLetter", value = "检索首字母", dataType = "java.lang.String")
   @Pattern(regexp="[a-zA-Z]{1}",message = "检索首字母必须是一个字母",groups = {AddGroup.class,UpdateGroup.class})
    private String firstLetter;    //检索首字母

    @ApiModelProperty(name = "sort", value = "排序", dataType = "java.lang.Integer")
    @Min(value = 0,message = "排序的最小值是0",groups = {AddGroup.class,UpdateGroup.class})
    @Max(value=10,message="排序的最大值是10",groups = {AddGroup.class,UpdateGroup.class})
    private Integer sort;    //排序

    private int version; //版本
}
